{% extends "BlackhouseappBluehouseappBundle:layout:layout.html.twig" %}
{% block title %}
    用户管理
{% endblock %}
{% block body %}
    <div class="page-header">
        <h2>用户管理 <small></small></h2>
    </div>
    <ol class="breadcrumb clearfix">
        <li><a href="{{path('members_list', { 'locked':  0})}}">可用用户 <span class="label label-success">({{activeCount }})</span></a></li>
        </li>
        <li>
            <a href="{{path('members_list', { 'locked':1 })}}">禁用用户 <span class="label label-danger">({{inactiveCount }})</span></a>
        </li>
    </ol>

    <table class="table  table-striped table-hover table-condensed">
    <thead>
    <tr>
        <th>用户名</th>
        <th>昵称</th>
        <th>信箱</th>
        <th>头像</th>
        <th>最后登录时间</th>
        <th>状态</th>
        <th>操作</th>
    </tr>
    </thead>

        <tbody>
        {% for entity in entities %}
            <tr>
                <td>
                    <a href="{{ path('user_show', { 'username': entity.username }) }}">
                    {{entity.username}}
                    </a>
                </td>
                <td>{{entity.nickname}}</td>
                <td>{{entity.email}}</td>
                <td>
                    <a href="{{ path('user_show', { 'username': entity.username }) }}">
                    {% if entity.avatar %}

                        <img  class="box_avatar" border="0"  align="default" src="{{vich_uploader_asset(entity,'userImage')|imagine_filter('small_image')}}"/>

                    {% else %}
                        <img src="{{ asset('bundles/blackhouseappbluehouseapp/images/user_default.png') }}"/>

                    {% endif %}
                    </a>
                </td>
                <td>
                    {{entity.lastLogin|date('Y-m-d H:m')}}
                </td>
                <td>
                    {% if entity.locked %}
                        <span class="label label-danger">已禁用</span>
                    {% else %}
                        <span class="label label-success">正常</span>
                    {% endif %}
                </td>
                <td>

                        {% if entity.locked %}
                            <a href="{{path('member_enable',{id:entity.id})}}" onclick="return confirm('您确定要启用{{entity.username}}吗？')"><button class="btn btn-default">启用</button></a>

                         {% else %}
                             <a href="{{path('member_disable',{id:entity.id})}}" onclick="return confirm('您确定要禁用{{entity.username}}吗？')"><button class="btn btn-default">禁用</button></a>

                        {% endif %}

                </td>
            </tr>

        {% endfor %}
        </tbody>

    </table>
    {{ knp_pagination_render(entities) }}
{% endblock %}